#ifndef LEAMOUTSTREAMHH
#define LEAMOUTSTREAMHH
#include "binary-out-stream.hh"
#include "leam-typedefs.hh"

namespace leam
{
    class ILeamOutStream
    {
    public:
	virtual ~ILeamOutStream(){}
	virtual void operator<<( licada::uint8 val ) = 0;
	virtual void operator<<( licada::uint16 val ) = 0;
	virtual void operator<<( licada::uint32 val ) = 0;
	//Read in characters placing directly into string.  Not sure
	//the c++ standard way of doing this exactly.  val.length()
	//should tell you the desired length.
	virtual void operator<<( const std::string& val ) = 0;
	virtual void operator<<( const licada::TDataVector& val ) = 0;
	virtual void flush() = 0;
	virtual void close() = 0;
    };
    
    class LeamVectorOutStream : public ILeamOutStream, public licada::VectorBinaryOutStream
    {
    public:
	virtual void operator<<( licada::uint8 val ) { 
	    licada::VectorBinaryOutStream::operator<<( val );
	}
	virtual void operator<<( licada::uint16 val ) { write( (licada::uint8*)&val, 2 ); }
	virtual void operator<<( licada::uint32 val ) { write( (licada::uint8*)&val, 4 ); }
	//Read in characters placing directly into string.  Not sure
	//the c++ standard way of doing this exactly.  val.length()
	//should tell you the desired length.
	virtual void operator<<( const std::string& val ) {
	    licada::uint32 len = val.length();
	    for ( licada::uint32 index = 0; index < len; ++index )
		data->push_back( val[index] );
	}
	virtual void operator<<( const licada::TDataVector& val ) {
	    licada::VectorBinaryOutStream::operator<<( val );
	}
	virtual void flush(){}
	virtual void close(){}
    };
}
#endif
